#!/usr/bin/env node 
const fs = require('fs')
const path=require('path')
const process=require('process')
// 名字
fs.readdirSync(process.cwd());
// 截取数组之后
let args=process.argv.slice(2);
let arr=fs.readdirSync(process.cwd());
if(args.length==0){
    dirfn()
}
function dirfn(a=__dirname){
    fs.readdir(a,(err,state)=>{
        err?Console.log(err):null;
        state.forEach(item=>{
            filesfn(path.join(a,item),item)
        })
    })
}
function filesfn(filepath,file){
    fs.stat(filepath,(err,state)=>{
        let type=state.isFile()?"文件":"文件夹";
        err?Console.log(err):null;
        process.stdout.write(file+"---"+type+"---"+state.size+"\n")
    })
}